package com.ljy.mapper;

import com.ljy.entity.User;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {
    @Select("select id,openid, username,  phone, gender,avatar, create_time, recent_time from user where openid=#{openid}")
    User getByOpenid(String openid);

    @Options(keyProperty = "id",useGeneratedKeys = true)
    @Insert("insert into user(openid,create_time,recent_time) values(#{openid},#{createTime},#{createTime})")
    void insert(User user);

    @Select("select id,openid, username,  phone, gender,avatar, create_time, recent_time from user where id=#{id}")
    User getById(Integer id);

    @Update("update user set username=#{username},phone=#{phone},avatar=#{avatar} where id=#{id}")
    void editUser(User user);
}
